How to use if statement when function returns 2 arguments?

You need to assign the returned values to two separate variables. Then you can validate either of them.

(uint256 index, bool exists) = checkIfPairExists(_token1, _token2);
if (exists == true) {
    // do something with `index`
}

As said in the above answer by @pert-hejda, you will need to assign the function return values then you can use those to check the condition. Why? Because multiple returns are represented as tuples and currently the feature you want is not supported in solidity. So, you will need to assign the return values and use those values in conditionals. Thank you.