It is best to pass the variables to the function
function2[eqn3_, eqn4_, x_, y_] := Module[{sol},
sol = Solve[{eqn3, eqn4}, {x, y}];
{x, y} /. sol
]
function2[y == 3 x, y == x^2 - 4, x, y]
Gives
{{-1, -3}, {4, 12}}
Otherwise, different context.
When you did this
function2[eqn3_, eqn4_] := Module[{x, y, sol},
sol = Solve[{eqn3, eqn4}, {x, y}];
{x, y} /. sol
]
function2[y == 3 x, y == x^2 - 4]
Then the x,y
in the equations are global context, but then you defined local x,y
inside the module, which are different context (even though they look the same on the screen), they are different symbols under the cover.