Matchmaking is decided by a combination of trophies and Town Hall level. If a player with a Town Hall level 10 has very few trophies, he can be pitched against all sorts of opponents, but the system will initially look for low-trophy opponents at the same TH level before widening the scope.

The trophy range for matchmaking is wide, to make sure players can find opponents at all times. This works both ways: sometimes you get attacked by an overpowered opponent, and sometimes you get the opportunity to attack a village that's no match for you.

If the trophy level between you and your opponent was huge, it was probably a Revenge match. You can seek revenge players who have attacked your village by clicking the Revenge button in th e Battle Log.  Attacking