Just had a similar problem on my Cat skidsteer. It would either not release until you hit the button several times or it would release & then lock while you were using it & not want to release again.
It was a bad coil on the parking brake valve. I replaced the whole thing for about $90.
Had to order & drove 50 miles to pick it up. They told me the part # & price of $38. When I got there the price was $90. We opened the box & could see it was the wrong part & part #. So they said they could order the right one & ship it to me but now the price was $90. I asked why it was $38 yesterday when I ordered & $90 today. The parts guy I talked to the day before had written down the right part # & price in his notes as $38.
He said the only thing he could figure was it was priced wrong in the system & when he pulled it up to look at it someone caught it & corrected the price.
So I had to pay $90 for it but they had it shipped to me UPS next day at their cost so I wouldn't have to drive the 50 miles again to pick it up.
Took about 15 minutes to change it out & so far no more parking brake problems.