Thanks to Andrei of School 205 Bucharest for this well explained solution.

The rectangle ABCD is a square because:- Triangles PEF and PAB are similar, they are both right-angled triangles, with a common angle. The similarity ratio is:
PE
PA
= EF
AB
(1)
Triangles PEH and PAD are similar, because angles PEH and PAD are equal and HPE is a common angle. The similarity ratio
PE
PA
= HE
AD
(2)
From (1) and (2)
AB
EF
= AD
HE
As HE=EF (sides of a square) Therefore AB = AD ABCD is a rectangle with two adjacent sides equal

Therefore ABCD is a square.

solution

Now, the construction of the inscribed square must be done in the following steps:

Note

The choice of point P, so that E is interior to the triangle PQR is not a restrictive condition, the construction is the same if E is exterior to triangle PQR.