A baby shower usually includes snacks - opening gifts - and playing a few baby shower games. On average, this will last as short as 90 minutes for a small group or up to 3 hours for a large group. Part of it depends on the number of guests and how many games you are going to do.
Two hours is a great target to plan for.
Remember, even when the "planned" events have finished, some people tend to stay longer just to visit.
So, if you are planning on going to a shower - you can always leave when the last planned event is over.
If you are going to throw a baby shower for someone - you can try to plan out the timing, but remember, there will always be a few people hanging around to the last minute talking even after events have ended.