How to transfer the ownership of a smart contract that has a proxy and was deployed using a Factory?

I have deployed a smart contract, with a proxy, using a factory.

I want now to transfer the ownership of this smart contract every time an ERC721 gets transferred. For that, I am using _beforeTokenTransfer, like this:

function _beforeTokenTransfer(
    address from,
    address to,
    uint256 tokenId,
    uint256 batchSize
) internal virtual override(ERC721EnumerableUpgradeable) {
    super._beforeTokenTransfer(from, to, tokenId, batchSize = 1);

    // if transfer is restricted on the contract, we still want to allow burning and minting
    if (!hasRole(TRANSFER_ROLE, address(0)) && from != address(0) && to != address(0)) {
        require(hasRole(TRANSFER_ROLE, from) || hasRole(TRANSFER_ROLE, to), "!TRANSFER_ROLE");
    }

    if(!coAllocatedSmartVault) {
        _setupOwner(to);
        _setupRole(DEFAULT_ADMIN_ROLE, to);
        _setupRole(MINTER_ROLE, to);
        _setupRole(TRANSFER_ROLE, to);
    }
}

The problem I am having is that the ownership of the smart contract I care about doesn't seem to be updated, despite all the methods are executing correctly in the blockchain.

This is the output from Remix:

status	true Transaction mined and execution succeed
transaction hash	0x2b6dc0cc9425220cfc6b15553596f9a7a898885e76764209e8be825486784a72
from	0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6
to	SmartVaultProxy.(fallback) 0xA6e869604FF568314debD938e1717a78bC1f658f
gas	315233 gas
transaction cost	305966 gas 
input	0x428...00000
decoded input	-
decoded output	 - 
logs	[
	{
		"from": "0xA6e869604FF568314debD938e1717a78bC1f658f",
		"topic": "0x8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76",
		"event": "OwnerUpdated",
		"args": {
			"0": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6",
			"1": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"prevOwner": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6",
			"newOwner": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4"
		}
	},
	{
		"from": "0xA6e869604FF568314debD938e1717a78bC1f658f",
		"topic": "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d",
		"event": "RoleGranted",
		"args": {
			"0": "0x0000000000000000000000000000000000000000000000000000000000000000",
			"1": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"2": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6",
			"role": "0x0000000000000000000000000000000000000000000000000000000000000000",
			"account": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"sender": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6"
		}
	},
	{
		"from": "0xA6e869604FF568314debD938e1717a78bC1f658f",
		"topic": "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d",
		"event": "RoleGranted",
		"args": {
			"0": "0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6",
			"1": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"2": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6",
			"role": "0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6",
			"account": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"sender": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6"
		}
	},
	{
		"from": "0xA6e869604FF568314debD938e1717a78bC1f658f",
		"topic": "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d",
		"event": "RoleGranted",
		"args": {
			"0": "0x8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c",
			"1": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"2": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6",
			"role": "0x8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c",
			"account": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"sender": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6"
		}
	},
	{
		"from": "0xA6e869604FF568314debD938e1717a78bC1f658f",
		"topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
		"event": "Transfer",
		"args": {
			"0": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6",
			"1": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"2": "0",
			"from": "0x525D885Bc1E047c9e8cce006914aCF9BE2fdA9f6",
			"to": "0xF8e6A72C0e72E0Eb510bD20097b0522Eae4B24E4",
			"tokenId": "0"
		}
	}

And this is the transaction in Polygon Mumbai: https://mumbai.polygonscan.com/tx/0x2b6dc0cc9425220cfc6b15553596f9a7a898885e76764209e8be825486784a72

What am I doing wrong? Is it possible that the ownership that is changing is the one from the proxy and not from the contract I care about?

This is the part I am worried about and that I don't understand from the output I just pasted:

SmartVaultProxy.(fallback) 0xA6e869604FF568314debD938e1717a78bC1f658f

How can I transfer the right contract ownership under this scenario?

I dont know which address belong to the implementation contract and which to the proxy, but make sure you are not calling the implementation contract but the proxy instead.