Showing a problem is $P$-complete
You need to show that for every $L'\in P$ there exists a logspace reduction from $L'$ to $L$. Your $f$ has $\langle M_{L'}\rangle$ hardcoded into it. The encoding was part of its definition, $f$ does not ask what is the encoding of the machine for $L'$ when it tries to compute $f(x)$.

One way to think of this is as follows: consider the sequence of functions $\left\{f_{s ,c}\right\}_{c\in\mathbb{N}, s\in\{0,1\}^*}$ where
$f_{s, c}(x)=\left(s, x, 1^{|x|^c}\right)$. Since $L'\in P$, there exists a function in this sequence which is a reduction from $L'$ to $L$ (the specific index depends on the machine deciding $L'$, but we don't really care about it).