I wanna preface this by saying I've never worked with Godot and I'm honestly a complete amateur with coding but I'd like to at least try to help.
I'm guessing the reason the player can move through walls on the first movement has something to do with a prioritization issue between the collision and movement script, aside from finding a way to fix the issue itself you could try making it so that the player is reset to the spawn position if they ever move somewhere out of bounds or change the movement system to where the player is "sliding" (like how the enemy moves) when you hold down a key instead of stepping each keypress.
For the enemy I have no idea how you did the script for it so I can't say much but you could try changing it's targeting to always move towards corners instead of just taking the shortest path or it could also work to lock it's movement to a sort of grid pattern; for example locking it's Y position unless it's X position is on a multiple of 10 and vice versa.
Like I said I have no experience with Godot so I'm really not sure how you would go about implementing the above ideas but I figured I'd at least try to give some starting points with fixes I would try if I was experiencing the same issues. Hope I helped a little at least, good luck :)