You can always choose to give your services/products/skills away to whomever you like. There is a loss (real or opportunity) in this approach, and there is hopefully a tangible positive outcome for the cause you are donating for. If the project is a one-off situation this is likely fine.
However there are benefits to setting up a nonprofit if you plan on this giving back being a regular thing. In many countries there are tax breaks for charitable gifts to registered nonprofits. Even work volunteered can be credited as a donation in-kind. I occasionally freelance as a well paid software engineer so if I donated a week of time it becomes a sizable break. (Note: in-kind donations are not deductible unless they are property. As an engineer I can donate intellectual/intangible property. Not all situations apply – seeor related in your context).
Further you can attract others to give as well. With the structure in place you can find ways to scale and repeat this process with others. Not everyone has this motivation or desire, but if you do you’d be better off getting a nonprofit up and running.
There are drawbacks to going the nonprofit route. There are is a good amount of administrative overhead (accounting, legal filings, registrations with local/national government, etc) and none of those pieces are free. If you aren’t sure which way to go I’d encourage you to contact an accountant who often works with nonprofits to help make sense of the costs involved where you live.