I cruised with several people who had booked back-to-back cruises, and they were not specifically guaranteed the same cabin for both cruises. They learned a day or two before the turnover day of their 2nd cabin assignment - in both cases, they were assigned the same one, which was quite convenient, as they didn't have to pack. They were allowed to disembark and do some sightseeing, but had to wait to re-embark until the ship was available for all oncoming passengers.
As "cruisemaster" pointed out, you will need to ask ahead of time about the logistics of all this. Sailing back-to-back itineraries is fairly common, though not by any means what the majority of cruise passengers choose to do.