I have a similar reaction when I help people with their computer problems and I get complimented as if I had just performed a magic trick, when in reality I'm usually just doing this:
Like it really isn't magic, most of the time it's not even difficult, it's just a problem solving technique that I've learned over the last few decades. Sometimes when I actually get to do something more interesting and hammer out some code it is a little more complex, but there again it's usually a matter of some googling to see how people usually do this thing and reading the documentation for the related language.
That said, if you are being paid to do this, be humble, but let them believe that it's magic.
Often times the easiest way to do that is to just say "Thanks" and then take a second or two to explain what you did. If the person really doesn't know anything about the tech you fixed for them, or the code you wrote, your explanation doesn't really mean anything to them, beyond "I worked my magic and now the problem is solved."
Realistically they're grateful that their problem is solved and they're happy to pay you for it, they don't really care how the trick is performed most of the time.
If you're not being paid to do it, or not being paid well. Teach them to fish, rather than giving them a fish. As in, don't take the wheel. Stand behind them, so you can see the screen, and walk them through the steps to solve their own problem. Point to the button that they might need to click rather than doing it for them.
Be careful with this though, being free tech support puts someone out of work, perhaps even yourself if they actually have an interest and learn quickly.
Also... Please don't write code for free. If you have to invest any significant time or effort to solve their problem, and it isn't something you would do for fun, you deserve to be compensated for your time.