Why does a directive only work when it is included inside WordPress directives?

When the directive is included as part of the WordPress directives

It simply needs to go before the WordPress front-controller. In fact, you should not include this as “part of the WordPress directives” as WP itself tries to maintain this block of code and could override your custom directives in a future update.

You should put this custom directive directive before the # BEGIN WordPress block.

It does not work if you put the directives “below the WordPress directives” because it is simply never processed. The preceding WP directives route all requests (for non-existent files/directories) to /index.php – after which processing stops and any mod_rewrite directives that follow are bypassed.

It would only work (with directives after the WP front-controller) if the “thank you” request mapped directly to a physical file on the filesystem – in which case the request is not rewritten to /index.php and processing is allowed to continue through the file.


Aside:

RewriteCond %{REQUEST_URI} ^(.*)?thanks?(/)$ [NC]
RewriteRule ^(.*)$ - [F,L]

This can be simplified to a single directive:

RewriteRule thanks?/$ - [NC,F]

The L (last) flag is not required when the F flag is used; it is implied.