Let language $L$ be denoted by the regular expression $a^*b^*$
What is wrong with the following “proof” that $L$ is not regular?
Assume that $L$ is regular. Then it must be defined by a DFA with k states, for some integer $k > 0$. Take the string $w = (a)^k (b)^k$ and split it $w = xyz$, with $y = ab$. Then $(wy^2) z$ is not in $L$, which contradicts the pumping lemma. Therefore, $L$ cannot be regular.
Revised to match the intended question.
You’re forgetting the statement of the pumping lemma: it says that you can split $a^kb^k$ as $xyz$ in such a way that $|xy|\le k$, $|y|\ge 1$, and $xy^iz\in L$ for each $i\ge 0$. The requirement that $|xy|\le k$ means that $xy$ consists entirely of $a$s. If $x=a^r$ and $y=a^s$, where $r+s\le k$ and $s\ge 1$, then $z=a^{k-r-s}b^k$, and for each $i\ge 0$ we have
$$xy^iz=a^ra^{is}a^{k-r-s}b^k=a^{is+k-s}b^k=a^{k+(i-1)s}b^k\;,$$
which is in $L$.