Recall your d = rt, distance = rate * time.
now, if the boat has a speed of say "b", and the current has a speed of say "c", when the boat is going upstream, is not really going "b" fast, is going " b - c " fast, because the current is eroding speed from it, going upwards.
And when the boat is going downstream, is not going "b" fast either, because the current is now adding to speed to it, so is really going " b + c " fast.
The time it took one way, is the same time it took back, 4 hours each way.
thus
what's the speed of the boat? well, 5 + c = b.