How can I prevent these pests from entering the garden? Do they come from the soil or fly to my tomatoes? I am open to most remedies, but would prefer a natural option if effective.
Montgomery County Maryland
Please give us more information. Is the pest primarily on your tomato? Can you send us photos of the larvae and damage.
You may be referring to the corn earworm also known as the tomato fruitworm.
They overwinter as pupae in soil throughout the southern U.S., and as far north as Maryland in mild winters. Weather fronts bring adult moths north, with arrival beginning as early as May. https://extension.umd.edu/hgic/topics/corn-earworm-vegetables
Take a look at monitoring and prevention/control including organic methods https://extension.umd.edu/hgic/topics/corn-earworm-vegetables
Also take a look at the publication from Va Tech and home gardens. In small gardens, hand picking and destroying wormy fruit and damaged pods can help eliminate the pest. https://www.pubs.ext.vt.edu/content/dam/pubs_ext_vt_edu/3103/3103-1537/ENTO-312.pdf
This looks similar to the tomato damage illustrated in the Va Tech link we gave you.
Since we don't have a photo of your caterpillar/larvae or insect itself, we can't be more precise at this point. When you cut open the tomato, do you ever find a worm inside? If you do, we'd like to see that. A view of the tomato interior would be helpful, too.
Besides the corn earworm (or tomato fruitworm) info we sent you, there is also a tomato pinworm, which can get into tomatoes. Take a look at this and read over the life cycle, monitoring and control options: https://extension.umd.edu/hgic/topics/tomato-pinworm-vegetables
This looks like a rove beetle. This is a predatory insect and is not causing the damage. They could be looking for insects to feed on. https://extension.umd.edu/hgic/topics/predatory-beetles