How can I stop monsters invading my mine/tunnels?

Solution 1:

Chances are they are spawning above you in the mine. Any kind of wall (stone or wood) except dirt will stop monsters spawning. I believe the walls are what stop monsters spawning unlike Minecraft's light level system.

If you've just dug straight into the earth, use the hammer to remove the dirt walls and replace with stone.

The other option is there is a blood moon on and the zombies broke through your house.