When you spontaneously visit someone, you drop by. If you happen to be biking past the house where your friend is cat sitting, you might decide to drop by and say hello.
To drop by is to pay a visit without planning ahead. You wouldn't drop by your cousin's house and settle in for a week — when you drop by, you don't stay long, and you keep things light and casual: "Maybe I'll drop by later and bring you some of those cookies I baked!" You could also use the phrases drop in or come by.