Google Maps claim that the trip takes four and a half hours (bus 862). Does it really take so long to travel 45 km?
No. According to the official website of Yehliu Geopark, the travel time is more like two hours (translation mine):
Yehliu <-> Tamsui Tamshui Bus Company, Ltd. or Keelung Bus Company, Ltd.: Service runs roughly every 30 mins, [and the] travel time [is] roughly 2 hours.
(Interestingly the travel time is omitted in the english version, which reads "Take the express bus (bound to Jinshan) at Tamshui station (near Tamshui MRT Station); alight at Yehliu stop. The bus comes every 30 minutes (the first bus at 05:50am and the last bus at 10:20pm).")
Edit: OP further asked what is the number of the "express bus" mentioned above. It is indeed Bus 862, according to a separate FAQ page from Yehliu Geopark:
Q : [General] How can one get there?
A : [...] 3. Danshui to Yehliu – Keelung Bus (no.862) / 1 hour 30 minutes / NTD 90
The details for that route show that the actual bus trip takes 3h51m and has 91 stops along the way.
If each stop is only 1 - 1.5 minutes (just a guess) then that's 2 hours of doing nothing at bus stops, and an average speed of about 25km/hr during travel.
Seems a little slow, but certainly not out of the realm of possibility ...