Some of this depends on the environment. Oil "attracts" sand. So if you leave on the beach, be conservative with wet lubricants. Graphite power is great for locks on the beach. If you live further inland, then WD40 isn't a bad choice for locks.
Yes oil doesn't actually attract sand, but wind-blown sand will stick to oily surfaces.
I just rebuilt several of my door locks and cleaned them using LPS-1 which as far as I can tell, is a superior alternative to WD-40 but maybe it does not displace water as well. I used an air compressor to blow any extra LPS-1 out of the locks. Now they feel better than new.
But, LPS-1 is much less messy. For general rust prevention, or when tools get wet, like working on plumbing, then a spritz of LPS-1 prevents rusting.
LPS-1 is "greaseless" so it should not leave a film behind but tools and especially firearms usually have a surface treatment (bluing, parkerization, whatever) which absorbs oil for protection.
Incidentally, LPS-1 and LPS-2 have distinctive odors which I assume is deliberate so they can be identified; LPS-1 smells like mint while LPS-2 smells like cherries. The oil recommended for musical instruments also smells like mint and is greaseless so I suspect it is the same as LPS-1.