The answer to 'how to prevent pest' is to take a comprehensive approach to pest control by implementing a combination of prevention methods and taking action at the first sign of an infestation. This includes sealing up entry points, eliminating food and water sources, and using targeted treatments when necessary.
Start by inspecting your home and yard for potential pest entry points, such as cracks, holes, and gaps around windows, doors, and utility pipes. Seal these up with caulk, weather stripping, or other appropriate materials to deny pests access. Eliminate sources of food and water by keeping your kitchen clean, storing food in airtight containers, and fixing any leaks or standing water. You should also regularly maintain your landscaping by trimming vegetation, removing debris, and keeping your yard clean.