Window air conditioners sit on the windowsill and typically have accordion-style fins on either side of the unit that act to seal off the window. Unfortunately, these are rarely anything close to air tight, and the air conditioner itself has to allow air in from the outside by virtue of its construction. Any hole large enough to let air through is potentially large enough to let a bug through. Luckily, there are a few things you can do to limit the open spaces for bugs come in.
Ensure your unit is installed properly. It should be seated directly on the window sill, and have a slight slope away from the building when viewed from the outside. The top portion of the window should be firmly seated against the top of the air conditioner case, and the vinyl panels on either side of the air conditioner should be extended and secured firmly against the molding. Additionally, make sure you are running your air conditioner with a filter, as this will not only increase the longevity of your unit but can cut down on bugs gaining access to your home.
Window Sash Gap
When a double-hung window is open, there is a gap between the sash of the bottom pane and and the glass of the upper pane. This is a prime entry space for bugs and other vermin. Seal this area using foam air insulation strips and duct tape. You can use colored duct tape to make the job less apparent, and have it match your interior wall color a bit more than the flashy silver stuff.
Vinyl Side Panels
The vinyl side panels are essentially just sitting against the molding, and are not creating anything resembling an air or bug-tight seal. Use foam applied to the sides of your window to give the vinyl panels a better seal. Apply the foam tape and then expand the panels out so they press against the foam. Secure the panels using the screws they came with when you are done.
Your window is designed so that the bottom of the bottom pane will form a seal against the windowsill. The window was not designed to seal against the top of an air conditioner. You can improve the level of air tightness between the window and the air conditioner by laying a thin strip of foam along the top of the air conditioner where the window will press against it.