Let's say, I am trying to do a double spend by creating two transactions almost immediately, is it possible that both the transactions are added in one block ? If yes, then which transaction is valid and which is invalid ? Also is there any specific order in which miners gather transactions in a block before starting to find proof of work ?
Bitcoin and other blockchain protocols enforce the constraint that any valid chain cannot have double spend UTXOs. If a miner were to include two transactions in a block both spending the same UTXO, the entire block would be invalid, and no other nodes in the network would accept it. If you were to create two transactions from the same UTXO and send them both out to the network, it would be up to the miners to choose which one to include. Some miners will prefer transactions that pay more fees, so those will tend to be included over the competing spend but most miners still adhere to "first seen safe", which means that unless a transaction signals being replaceable (replace by fee), it will get included over a later, higher fee version.
If you create two transactions that use some of the same UTXO as inputs, every node will perceive only one of them as valid. By default, this will be the one that nodes first see: once a node learns about a transaction, it considers the UTXO used in the inputs to be spent from the perspective of the mempool. When the node sees the second transaction, it considers the second transaction invalid for attempting to claim inputs that are already marked as used.
When replace-by-fee (rbf) was signaled in advance, the second may replace the first, but then the first is evicted from the node's mempool.
In any case, there will never be more than one transaction spending the same input considered for block inclusion at the same time.