I think that the secret passages are more often a way for the servants to do daily maintenance without disturbing the owner and guests. In rare occasions they were used so that the lord/lady can visit a lover without bringing unnecessary attention.
Anecdote: I was attending a drinks party at a friends house and nearly shit when a bit of wood panelling suddenly opened up next to me.... only for a young lady to appear with a tray of canapes.
Here, quite a few large 18th & 19th century houses were built with separate, discrete, servants staircases and passageways.
This is the case for the castle in Versailles (obviously not medieval).
There areplenty of doors (more or less visible) that are used to split the public and private activities (and a way for servants to better navigate the castle).
The doors are not always hidden - they clearly separate these two worlds, and may also led to very nice places that are just not public.
A company we were consulting for bought a big old country house here in the UK. It was completely empty when my small team moved in. I took the massive library as my office.
Hah, sounds like a quick getaway unless the tunnel was leading to a private and usually unoccupied bedroom so that sir spending time in reading books did acquire a new meaning.