It's easy to understand spending time is a figurative usage from spending money, as people say "time is money".
I bet you definitely familiar with the same idea when people say "time has passed." In the context, time is a parallel to a lively animal that can cross by you. It is 过 in Chinese to convey this meaning of passing through.
我在公园花了三个小时(+做什么事 doing sth)。 I spent 3 hours in the park.
我在公园，三个小时就过去了。 3 hours has passed since~
我在中国过了三年. I stayed in China for 3 years.
我花三年的时间留在中国 I spent 3 years staying in China.