4 wires in single-pole switch
If you count the numbers of lights, fans and sockets in your home, and then count the number of circuit breakers assigned to those things, you’ll notice you have a lot more outlets than circuit breakers.
That’s because each circuit powers more than one outlet/lamp/etc.
How does that work?  Hot, neutral and ground go to an outlet point like a light switch.  And then, another hot, neutral and ground goes onward from there to another outlet.  That’s normal.  You walked right into the middle of that.
You were expecting to see 1 always-hot, 1 switched-hot and 1 ground going to your switch.  What you actually found was a supply always-hot; an onward always-hot; and a switched-hot.  And a ground.
The supply and onward always-hot wires should have been kept together.
I gather that since the light works, your loose, unaccounted for wire is the onward always-hot.  Where do we attach that?  With the supply always-hot.
If you have no idea which that is, it won’t hurt anything if you accidentally attached it to switched-hot - just at that point it will be switched.  Don’t leave it that way, the smart switch may not be strong enough to switch whatever it goes to.