Cookies are used for double-submit CSRF protection pattern. One copy of the CSRF token is put into a hidden form field, and the other is in a cookie.
https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Re...
https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Re...
(It's also not clear to me that cookies are required, if there are other technically sound options that do this without setting cookies.)