Claim: The perimeter of $\Delta AEF$ is 10 no matter where it is drawn.
We proceed by giving a way to construct the point $F$ on $AB$ once a given point $E$ on $AD$ is chosen, assuming $E$ is interior to this interval. First construct the circle $K$ centered at vertex $C$ of the square, of radius $5$. Then $K$ is tangent to sides $AD$ and $AB$ at the points $D,B$ respectively. Now from $E$ construct the other tangent to circle $K,$ which meets $K$ at the point $P$ and when extended meets side $AB$ at some point $F.$
We have $ED=EP$ since the lengths of tangents from a point outside a circle are equal, and similarly $FB=FP$. We now have congruent right triangles $\Delta EDC \equiv \Delta EPC$ and also $\Delta FPC \equiv \Delta FBC.$ We therefore have
$$\angle DCE= \angle ECP =x, \\ \angle PCF = \angle FCB = y.$$
Two copies each of $x,y$ then fill out the whole 90 degree angle at corner $C$ of the square, and so $x+y=45=\angle ECF.$
There can only be one point $F$ on $AB$ which makes $\angle ECF=45,$ so the above construction has given the desired point $F$.
But now a series of equalities shows the perimeter of $\Delta AEF$ is always $10.$
$AE+AF+EF = AE+AF + (EP+PF) = (AE+EP)+(AF+FP)$
$= (AE+ED)+(AF+FB)=AD+AB=5+5=10.$
A trig approach (requested by OP in a comment)
The square is ABCD where say A is the upper right, B the lower right, C the lower left, and D the upper left vertex of the square. Then the point F is on the right vertical side, and E is on the top horizontal side, with the angle FCE given to be 45 degrees. Let $x$ be angle BCF and $y$ be angle DCE, so that $x+y=45$ degrees.
For notation let $t(\theta)=\tan \theta.$ Then $BF=5t(x)$ and $DE=5t(y),$ and since all the sides are 5 we have
$$ FA=5(1-t(x)), \\ EA = 5(1-t(y). \tag{1}$$
Using Pythagoras' theorem to get the diagonal of triangle EAF gives
$$EF^2=FA^2+EA^2=25[(1-t(x))^2+(1-t(y))^2] \\
=25[ 2-2(t(x)+t(y))+t(x)^2+t(y)^2]. \tag{2}$$
Now since $x+y=45$ and tangent of 45 is 1, we get from the sum formula for tangent that $(t(x)+t(y))/(1-t(x)t(y))=1.$ This means we can replace $t(x)+t(y)$ in $(2)$ by $1-t(x)t(y).$ When this is done we find we get $EF^2=25[(t(x)+t(y))^2]$, which means $EF=5(t(x)+t(y).$ When this is added to the sum $FA+EA$ the result is the constant $10$ because the tangents cancel, making the perimeter of the triangle $AEF$ constantly $10$ independent of the angles $x,y.$
Analysis:-
We want to construct the rectangle ABCD inscribed in the $60^0$ - sector OPQ such that $AD = 2AB$.
Our 1st target is find $\theta (= \angle AOD)$.
Applying sine law to $\triangle OAD$, we have
$\dfrac {1}{\sin (30 - \theta)} = \dfrac {2}{\sin \theta}$
… Using compound angle formula, and special angle values and rationalization, we have …
$\tan \theta = \dfrac {\sqrt 3 - 1}{2}$ ($= 20.xxx$ degrees approx.)
Our next target is to construct such $\theta$.
Drop $PR \bot OQ$ cutting $OQ$ at $R$. (Note that $OR = 1, OP = 2, PR = \sqrt 3$.)
Draw circle $OSQ$ (centered at $R$, radius $= RO$) cutting $PR$ at $S$. Then $PS = \sqrt 3 – 1$.
Draw the blue circle using PS as radius.
Through P, draw the perpendicular to OP, cutting the blue circle at T (a point nearer to Q). Then, $\triangle POT$ meets our requirement with $\angle POT = \theta$.
The point where OT intersects the red arc is our point D.
Reflect D about the angle bisector of $\angle POQ$ to get C. It is not difficult to get B and A.
NB Construction of D is simple but the analysis is a bit involved.
Best Answer
Let $\angle DMA=\angle BMA=\alpha.$
Observe, $$\angle BAM=90^{\circ}-\angle DAM=\angle DMA=\alpha.$$ $$\implies BM=BA=2.$$ Using the Pythagorean Theorem, $CM=\sqrt{3}\implies DM=2-\sqrt{3}.$