Assuming it is a new machine, then it sounds like you didnt lock the portafilter into the group head tight enough.
It should lock in at least so it is sitting straight out of the machine or maybe a little to the right.
Maybe you put too much into the basket. A good rule to start with is you want just enough that you can lock the portafilter in and a 5 cent piece rested on top of the tamped coffee grounds will leave a slight impression but not be mashed into the puck (just lock and unlock, dont pour a shot).
There needs to be enough room for the coffee to expand when it is exposed to the hot water.