You’ve put the redirect code in the wrong place. It needs to go before the # BEGIN WordPress
section. By placing the redirect code after the WordPress front-controller it will never be processed unless the request is for a physical file.
However, your first attempt is not correct (it’s missing the check for HTTPS), so would result in a redirect loop (if it was executed).
A standard HTTP to HTTPS would take the following form:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
However, ideally you should also combine this with a canonical www/non-www redirect as well, to avoid duplicate content or multiple redirects. For example, if the preference is for www (and you have no other subdomains), then something like the following:
# Redirect bare domain to www and HTTPS
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
UPDATE: If your preference is for the non-www version, then you can change the first rule to read something like:
# Redirect www to non-www (and HTTPS)
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule (.*) https://example.com/$1 [R=301,L]
(Assuming you’ve also changed the necessary settings in WordPress as well.)