1. She hid her diary under the carpet.

2. She hid her diary beneath the carpet.
[Which one is correct? Can we use both?]

They are both correct. Here are the examples for you.

UNDER
in, to or through a lower place/ position
My dog used to sleep under our bed, but he’s grown too big now to do that.
BENEATH (formal)
in or to a lower position, under
My cat always hides beneath the sofa when I have visitors.