They can. Heavy rain can flood or disturb outdoor nesting areas and change where ants search for food and shelter.
If you see a lot of ants coming inside right after a storm, that doesn’t mean that the colony necessarily started indoors. What’s most likely happening instead is that the ants have been displaced by the rain and they need somewhere else to go in a hurry. Your home happens to be convenient.
Water can saturate soil, and this disrupts nests. It makes the normally usable outdoor spaces which ants would occupy a lot less suitable. That leaves ants searching for drier areas where they can find both shelter and food.
As for how ants get into your home, they’re very small so they have a lot of good options. Small gaps around doors, windows, foundations, utilities, and other exterior seams may provide entry routes. Once inside, crumbs, sugary residue, pet food, and grease can keep them well fed. They also like moisture (when it’s not actively flooding their nests) which is why they show up around plumbing. These things can keep them around.
Rain can also make preexisting activity more visible. The ants may already have been living close to the structure for a while, and, owing to the rain, simply changed their foraging route.
If trails appear after wet weather, follow them as far as practical to see where they enter. Once you do that, seal up gaps as you find them. Indoors, fix any leaks or moisture problems that you can and clean up food residue as you find it.
If ants are becoming a problem around your Los Angeles property, Mosquito Squad of Los Angeles can help with pest control around the property. Call (818) 350-8870 or request a free quote online.