It's a fun hobby, isn't it? :)
Trivial point first: if you're getting into game dev then I'd encourage you to leave degrees behind and move to radians. Degrees are cost for no gain and radians come naturally from the geometry. PI radians is 180 so rather than 45 degrees, try to get into the habit of using PI/4. No big deal though.
I assume all the code is in your
_physics_process method. Yeah, that's going to produce some very erratic behaviour. It'll only rotate when the front one is colliding. PI/4 radians at 60fps is 7.5 rotations per second. Plus the rotations stack. You might get dizzy! :)
Also, you're rotating the object on multiple axes. You have to be really careful about Euler rotations, they're a bit like Rubik's Cubes, once you do them they can be very hard to undo and your result is going to be chaotic. Here's a great piece about the pitfalls that I'd encourage you to read:
Can I ask what you're trying to achieve here? Are you looking for the object to turn towards / away from the collision? If so then the dot product is likely what you need.