Trademark oppositions may be filled by anyone who has real and legitimate interest in the outcome of application examination proceedings. Usually, this person is a proprietor of an earlier trademark.
It's worth pointing out that even if anyone can raise an opposition, some IP offices are not bound to act upon all of them equally. They will act upon oppositions filed by holders of existing trademarks but not necessarily other outside parties.
In the US, there are two additional types of opposition. Any party can oppose a trademark if they believe the trademark was not filed in good faith - that is - bona fide. This applies to the intent-to-use applications (1B). These should be filed with an intent to start using the trademark in commerce in the foreseeable future, which can theoretically be exploited by someone squatting on the trademark. The opposer must show that the applicant did not have a bona fide intention to use the mark in commerce.
The second type is very similar but applies to applications filed on a use-in-commerce basis (1A). This type of application is intended for trademarks that are already commercially active. Again, the lack of bona fide use in commerce can lead to receiving opposition from any third party that believes this is the case and provides supporting evidence.