Say I create a product that I release for free and take no profit in any way. If this product somehow violates the copyrights or trademarks of another company, is there risk of needing to pay for damages to that company?
Yes. Money damages can be awarded in this circumstance and would likely be awarded if the infringement was found to have occurred and not to have been fair use.
Even in the absence of proof that any profits are made, there are statutory damages that can be awarded on a per offense basis for copyright violations, and trademark cases in addition to having statutory violations can measure damages by harm to the trademark owner and not just unjust enrichment to the infringer.
Yes. Even if you didn't profit from the violation, the company may have incurred losses because of it (e.g., lost sales because somebody was giving away copies of their product for free).