Generally speaking you cannot buy a home if it’s already under contract since the seller is legally obligated to transact with the purchaser listed in the contract. However, a home which is under contract can become available again if a contingency triggers the cancellation of the contract.
A home which is under contract may also become available again if the buyer defaults under the contract and fails to close.
If you’re in love with a property which is under contract, it may still be a good idea to submit an offer so that the seller becomes acutely aware of your interest. However, don’t expect your offer to be accepted or for the seller to engage in a negotiation unless the original deal falls through.