No ground plane, no bypass cap, looks like you're getting expected results.
Given the bad design that is clearly evident, I'm guessing you also didn't put a flyback catch diode across the solenoid either.
Elaborating on all these things is pointless since they are really basic and already well covered here and other places. Add the flyback catch diode and a bypass cap for each power pin of the micro. That's the bare minimum necessary to fix this mess.
If you can use one layer mostly for ground with "jumpers" in it only to make routing work on the other layer, that would be good. I don't know why you're using all ancient thru hole parts, but since you are, I'd use the top layer for ground and put as much of the interconnects on the bottom layer as possible.
Added:
Others have pointed out that D1 is the flyback catch diode (as I said earlier, I hadn't looked and was guessing). That's one problem down, but still leaves the two major problems of missing bypass cap (or caps, you need one for each power pin), and bad grounding.
This also points out why you need to show the schematic. You can't expect the volunteers you are seeking a favor of to try to follow the layout to infer the circuit. A schematic would also have made the lack of decoupling capacitor obvious, and should show what type of diode D1 is.
On the flip side, grounding is a layout issue. I see you have meanwhile redone the layout using a mix of surface mount and thru hole parts. In this case I would use the bottom layer as a ground plane to the extent you can. Put the interrconnects on the top layer, going only to the bottom layer to make short "jumpers" for when things can't be routed in a single plane. Try to keep those jumpers as short as possible and away from each other. The metric to strive for is to minimize the maximum dimension of any island in the ground plane. That not only tells you to keep the jumpers short, but to not clump them together.
I see you got some bad advice in the comments to your question, which was unfortunately upvoted. Electrically, direct connections without any bends is best. What you had originally between the microcontroller and the keypad connector was perfectly fine, in fact even optimal. Don't let people tell you it should be different due to misguided and silly asthetic reasons. The electrons don't care how pretty you or anyone else thinks it looks. When you do need to make bends, the comment is correct in that you should try to avoid anything more than 45°. To make a 90° bend, use two 45° bends with a short straight segment between them. You actually did this just fine in your original layout.
Again though, you need to show the schematic to get more meaninful feedback.