Category pages resolving with and without category prefix

I didn’t find the cause. But I was able to hack a solution into functions.php:

add_action("wp", "disable_duplicate_categories");

function disable_duplicate_categories() { 
    if (is_category()) {
        $urlParts = explode("https://wordpress.stackexchange.com/", $_SERVER["REQUEST_URI"]);
        if ($urlParts[1] !== 'category') {
            array_splice($urlParts, 1, 0, 'category');
            $url = implode("https://wordpress.stackexchange.com/", $urlParts);
            header("Location: ".$url,TRUE,301);  
            exit;
        }
    }
}

The unwanted pages are never linked to, so the slight delay from redirecting after some of the server code runs and calls the database is unimportant.

I have some code in the theme that’s dependent on The SEO Framework, so ruling that out wasn’t possible without a lot of messing about. If anybody has a clue as to why the category archives resolve without the category base please share.