when do I use 东西 instead of 件事 to express "something"
「東西」 means a "thing", a generic word for any object. 「那是甚麼東西？」 "What is that thing?" Food is obviously a subset of "things". There are many times you can refer to an object as 東西, like a toy, a pen... you name it.

「一件事」 is referring to an event (事件), or something that has happened.