Fridge turns on when banging it
It could be a door switch but also could be the contactor or relay that runs the compressor has bad contacts. Sometimes wiggling them will allow them to seat so it starts again, if it is getting worse over time I would probably replace first you could test Jraef’s theory by opening the door while it is running if it keeps running it’s the contactor or relay.