I think this sort of thing usually happens when the cruiseline is repositioning its ship. In other words they have been running one itinerary on the ship for a while and now are changing to a different one.
This happens for instance in the spring and fall with ships that cruise in Europe say, during the summer, and in the Caribbean during the winter. The line has to get the ship back from Europe in the fall to begin its winter schedule but they don't want to miss out on revenue during the time it would take it to transit the Atlantic, hence the repositioning cruise.
It also happens in cases where the desired itinerary is in a long straight line ( eg up the Alaska coast. Some ships will do a 7 day northbound cruise starting in say Seattle and ending in Seward then do a seven day southbound cruise in reverse. In that case, people with the time and inclination can do back to back cruises and end up where they started.
There are also cruises which leave from Mexico or Canada and end up in Hawaii (or vice versa) this is because of some weird maritime laws which I won't go into here.
The Miami - San Juan situation at first glance doesn't seem to fot into any of those categories so without more details I can't tell you why they are doing that here.
Thanks to all of you for your responses. They all make perfect sense now. Tom, you're probably right about the Miami-San Juan deal. I only wish I had the time (and money) to take 14 days to sail. Guess I'll have to keep playing Lotto.