From the NCAA website:
Selecting the 32 At Large Bids:
These teams are chosen, sometimes controversially by a committee that considers each team's
- season ending national ranking
- season ending win-loss record
- opponent strength
- strength of the team's playing schedule
So if during the your team's season you played and beat tough teams then that would count much more than playing against and beating easy teams.
Based on all this info they "seed" the tournament brackets, which means they place each team in a spot according to who they have figured out should be ranked or seeded first, second third all the way to the 64th team in the country.