It's not exactly rocket science, somewhere between the bulb and the holder there is increased resistance or it is going open circuit, Either due to a build up of shit/corrosion, The bulb is not tight in its holder, The spring pressure is not strong enough to hold the contact against the globe or a wire is plain and simply not making correct contact.
By hitting it you are making something move and make contact, Think about it for a second.
You fix it by using your eyes to find where the problem is, Or get a test light and trace the path of the indicator light wiring to see where it is going open circuit.