SEO friendly URLs in the online shop [duplicate]

This question already has an answer here:

  • Is a URL with a query string better or worse for SEO than one without?

    2 answers

Product pages on the website I create may have multiple categories / URLs. Therefore, canonical URLs are used. The main product URLs are unique and predictable.
/ products / productname-id

When considering categories, however, I have two options. Examples:

Option 1: Use URL Parameters to Display Categories:

/ products / nike-pegasus-id? cat = / men / training
/ products / nike-pegasus-id? cat = / men / running
/ products / nike-pegasus-id (canonical URL)

Option 2: Use folders in the URL to display categories:

/ products / men / training / nike-pegasus-id
/ products / men / running / nike-pegasus-id
/ products / nike-pegasus-id (canonical URL)

Site Search and Sitemap offer only the simple URL version with no categories.
My question: which option is better for SEO and why?