I’m from Slovakia, traveling threw USA with ESTA visa. I didn't want to go to Mexico, but now when I'm near the border, I decided to go...but I don't know.. can I go there with my visa and then just go back to USA or do I need any special allowance?
Strictly you are not on an ESTA visa. ESTA gives you permission to get on a plane. It's a Visa Waiver that lets you into the country. I assume you are a Slovakian citizen, since they qualify for Visa Waiver.
Yes, you can exit the USA and go to Mexico and re-enter from Mexico (assuming you are allowed to enter Mexico - I know nothing about that). Be aware that the time you are in Mexico counts towards your 90 days allowance in USA, and the clock does not reset. So you still have to leave USA at the end of your trip 90 days or less from when you arrived.