For the Grand Canyon, my recommendation is to camp in the Grand Canyon National Park. There are two developed campgrounds at the South Rim (see the website at the link below.) Flagstaff is a 60-90 minute drive from the Canyon; a little too far to be convenient. The Park campgrounds are very popular in summer, so having a reservation at Mather would be an advantage. Otherwise, you need to arrive in the morning to secure a campsite.
"Dispersed camping" means camping on your own, without any amenities like water, bathrooms, etc. This is typically allowed in the National Forest areas. Around Flagstaff and Sedona is the Coconino National Forest, closer to the Grand Canyon is the Kaibab National Forest. You can read about dispersed camping in the Coconino NF here:
You might really enjoy camping near Sedona. These are developed campgrounds, some are more rustic than others, and some can be reserved.
The driving distances in the southwest are quite long and, in general, trying to stay in one place and see different areas ends up being inefficient. It's best to move camp and stay near the places you want to visit.