I think that you assumed that:
2k - 1 = k + 2
However we can't do this, because a square has 4 sides whilst a triangle only has 3 sides.
This means that we can say
4(2k - 1) = 3(k + 2)
We multiply by 4 due to 4 sides of the square, and by 3 due to the 4 sides of the triangle.
Lets expand the brackets, and solve it:
4(2k - 1) = 3(k + 2)
8k -4 = 3k + 6
5k -4 = 6 ( subtract both sides by 3x to collect the x values)
5k = 10 (add both sides by 4 to get the x's alone)
k = 2 (divide both sides by 5 to get what just x is)
So k = 2 units