The reason there are multiple, contradictory answers is because this problem is overconstrained. There is 1 unknown (the angle of initial velocity), yet there are 2 equations:
The x position after 2 seconds is 6, 2vx = 6
The y position after 2 seconds is 0, -g*2²/2 + vy*2 = 0
Since the problem is overconstrained, that means that, unless the solution to the first equation just so happens to equal the solution to the second equation, this problem is unsolvable.
Alternatively, we could phrase it as there being 2 unknowns (the x velocity & the y velocity), and 3 equations:
The x position after 2 seconds is 6
The y position after 2 seconds is 0
The magnitude of the initial velocity is 5m/s, vx²+vy² = 5²
Either way, the point still stands that this equation is overconstrained by one degree of freedom.
I have a hypothesis, however, and that is that the person who made this problem meant for the value of g to be an unknown (say, if this takes place on another planet, or if you're on a plane traveling in a parabolic arc).
If that were the case, then we'd have 2 equations and 2 unknowns. Or, 3 equations and 3 unknowns, which, actually, doing it that way makes it easier:
vx*2 = 6
-g*2²/2 + vy*2 = 0
vx² + vy² = 5²
2vx = 6, so vx=3
-g*2²/2 + vy*2 = 0, -2g+2vy = 0, vy = g
vx²+vy² = 25, 9+vy²=25, vy² = 16, vy = ±4.
g = vy = ±4.
Presumably, the gravitational constant is positive.
So, the gravitational constant would be 4 m/s² downwards, and the initial velocity would be 3m/s horizontally and 4m/s upward.
Though technically, it is also possible for the gravitational constant to be negative (for instance, in an aircraft accelerating towards the earth faster than 9.81 m/s², which would simulate negative gravity), in which case the gravitational constant would be 4 m/s² upwards and the vertical component of the velocity would be 4 m/s downwards. However, I'd probably disregard that as a possibility, as it is typically outside the realm of standard physics curricula.
Again, this was just a hypothesis. But as we can see, for this problem to be correct, either the gravitational constant cannot equal 9.81m/s² like it is on Earth, or there must be some other factor that wasn't mentioned in the initial problem.
Since the equation having a different gravitational constant wasn't specified in the initial problem, however, it might not be wise to jump to that conclusion. On the other hand, though, since this problem is unsolvable under the assumption that g=9.81 (or 9.8, or 10, depending on which one they want you to use)...I guess it couldn't hurt? Worst case, you get it wrong. Which you were already going to do, unless you either magically read the teacher's mind and figured out what answer they wanted you to put down, or unless the teacher realized the problem has no solutions and decided not to count that problem.

Frank T.
10/02/24