I did this itinerary on a Princess ship last April for a "conference at sea" for work. I have been to Mexico a lot, so it was not my first time in any of these ports. It is pretty easy to get off the ship and walk around on your own, except in Puerto Vallarta you will need to take a taxi to get away from the commercial port where the cruise ships dock.
In Mazatlán it is really easy to walk from the ship to the Historic Old Town (there is a color coded sidewalk) where you will find historical buildings, local markets, a tribute street to the Beatles, and Mazatlán's version of cliff divers (maybe 2-3 miles of walking in total). There are lots of small shops and restaurants as well. If you want to visit the Golden Zone where all the resorts and beaches are you will need to take a cab.
In Cabo you will not be docked. The ship will anchor and you will get to shore by tender. It easy to walk around the Marina area and there are lots of shops and restaurants and bars, but it is pretty one dimensional. I was done in an hour. If you want something more interesting, you should charter a panga and go fishing or sign up for a formal shore excursion tour.
In Puerto Vallarta, you can catch a cab and go into Old Puerto Vallarta and walk the Malecon and visit the shops and restaurants. There are a few historical buildings etc., but mostly tourist stuff. But Puerto Vallarta is a big city and with a little research you may find something more interesting to you.
In all three ports, if you don't want to book excursions through the ship, you can often save money, or find different tours, booking through
https://www.viator.com/. But if you are late getting back to the ship using an independent operator you may end up being a dock runner, whereas, supposedly, if you book through the ship, and the tour is held up for some reason, the ship will wait for you.
If you are looking at fishing in any of these ports, I have had good luck using this website -
https://fishingbooker.com/. Usually if you tell them you are interested in fly fishing they will let you know if they can accommodate.
In general, the tourist areas in Mexico are pretty safe, but just like in the USA, you should always be aware of your surroundings.