Welcome to FlyerTalk!
Is Cancun your first stop in Mexico? If so you will go through both immigration and customs.
If you are changing planes elsewhere in Mexico (i.e. Mexico City), you'd clear Mexican immigration at your first Mexican airport of entry. Then customs in Cancun. In this case you won't see your checked luggage, if any, until Cancun.
Mexican customs is a random affair - you are asked to push a button on a "traffic signal". Flashes green, you're good to go. Flashes red, your bags are inspected. And customs agents reserve the right to inspect any bag even if you get a green light.
For tourists the whole process is generally quick and painless. You shouldn't have any problem making your connection assuming your flight to Cancun is on time.