Function not approving the NFT through interface

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract Test {
    function transferToken(address _contract,address to ,uint256 _tokenId) public{
        // IERC721 token = IERC721(_contract);
        IERC721(_contract).transferFrom(msg.sender, to, _tokenId);
    }
    function transferToContract(address _contract,uint256 _tokenId) public{
        IERC721 token = IERC721(_contract);
        token.safeTransferFrom(msg.sender,address(this), _tokenId, "");
    }
    function approveNFT(address _contract, address operator, bool approved) public{
        IERC721 token = IERC721(_contract);
        // token.setApprovalForAll(msg.sender, approved);
        token.setApprovalForAll(operator, approved);
    }
    function checkName(address _contract) public view returns (string memory){
        ERC721 token = ERC721(_contract);
        return token.name();
    }
    function checkSender() public view returns (address,address){
        return (msg.sender,address(this));
    }
    function isItApprovedForAll(address _contract,address owner) public view returns (bool){
        IERC721 token = IERC721(_contract);
        return token.isApprovedForAll(owner,_contract);
    }
}

I'm trying to make auction contract for nft for this purpose first I need to give permission for auction contract to tranfer user's nft . I tried giving permission to auction contract using IERC721 Openzepplin standard but it is not working as expected.

Current Behavior : when function approvenft() gets executed the fuction isitapprovedforall() shows true but while transfering nft it shows "ERC721: caller is not token owner nor approved" and also the IERC getapproved() function is not showing shows the newly approved address

Expected Behavior : after approving the nft using approvenft() it should be transferable.

    function approveNFT(address _contract, address operator, bool approved) public{
        IERC721 token = IERC721(_contract);
        // token.setApprovalForAll(msg.sender, approved);
        token.setApprovalForAll(operator, approved);
    }

This will not work.
The msg.sender that token.setApprovalForAll received is the contract, not address that called your approveNFT function. So what the token.setApproval receives is a requests that will approve the transfer from your contract for your contract, not from the wallet address for your contract.

The user will have to call setApprovalForAll on the token himself with your contract address.