1. Pan often hid behind the trees in a dark corner.

2. He often hid behind a chair in the room.
===========
What does 'in a dark corner" modify in #1?

What does 'in the room' modify in #2?

Both are prepositional phrases which modify the noun immediately preceding it:

"in a dark corner" modifies "trees"
"in the room" modifies "chair"

If you want each prepositional phrase to modify the verb in each sentence, then move it so it's immediately after the verb.

Pan often hid in a dark corner behind the trees.
He often hid in the room behind a chair.