In solidity there are function modifiers called virtual and override.
That means, when you mention a function is virtual, you are hinting to the compiler that the function is going to be override in the derived contract. Which is solidity compiler is looking forward to.
In the first block of code, you are importing only erc721URIStorage. While ERC721URIStorage contract importing the ERC721 contract.
So when you try to import the ERC721 contract twice in the second block of code, it is asking you to override virtual functions with same function name.
If you do that, the error is going to be:
If you look at the picture the error says:
TypeError: Derived contract must override function "_burn". Two or more base classes define function with same name and parameter types.
TypeError: Derived contract must override function "tokenURI". Two or more base classes define function with same name and parameter types.
When you are inheriting the erc721 contract twice, you will have two _burn and tokenURI functions. So having two functions with the same name and parameters isn't allowed in any programming language(the compiler throws error) and on top of that they are virtual functions.
Tell me if it helps!
You can read more about inheritence here