To trim only trailing slashes use rules from Trailing Slash Problem Apache's guide:
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]
To removes all trailing and duplicates slashes in the path, includes a root of the path, see this post I described: https://stackoverflow.com/a/79647129/6243733