9mph is the boat's actual speed. 12mph with the stream and 6mph against the stream. 12mph takes 2 hours to get there and 6mph takes 4 to get back = 6hours.
To get speed you do Distance/Time.
The speed of the motorboat in still water is 9 mph. It travels at 6 mph against the current and 12 mph with it. This speed allows the total trip to take 6 hours as given in the problem.
;