how are lightning network payments instant and secure at the same time? I have a question regarding lightning network. It's a bit of a long question so please bear with me.

If have 1 bitcoin in my wallet and buy an item costing that amount from a shop. I leave the shop before they have a confirmation (before it's put into a block).

It's my understanding this would put the shop at risk as i still have the 1 bitcoin technically in my wallet as the transaction with the shop is still floating around in the meme pool.

I could at this point create a new transaction sending the 1 bitcoin to another wallet owned by myself. I could attach a relatively large miner fee to this transaction.

This transaction would probably then get put into a block before the shop transaction. If this happened the shop transaction would now be considered invalid as according to the block chain i now have 0 bitcoin in my wallet.

This is why the shop needs to wait for 1 confirmation before allowing me to walk out of the shop with the purchased item.

The problem here is i could potentially be waiting for around 10 minutes before confirmation is received. Bitcoin isn't exactly user friendly from the shops point of view.

I have heard lightning network solves this issue but i don't fully understand why.

My understanding is to open a LN channel with the shop a transaction is created on the main bitcoin block chain.

This transaction would be saying to take 1 btc from my wallet and 0 btc from the shop's wallet and open a multi sig wallet. My understanding being the multi sig wallet is a temporary address which will remain active until the LN channel is closed. When it's closed a new transaction would be created distributing the funds to my wallet and the shop's wallet depending on where the funds were in the LN channel when the channel was closed.

My question is how do confirmations work with regards to the initial transaction which opened the LN channel? When the LN channel is opened presumably this transaction is in the meme pool.

Can i send the 1 btc to the shop in the LN channel while that transaction is still in the meme pool? If yes then surely it's the same situation as before where i could then create another transaction on the main blockchain for 1 btc and if that transaction gets put into a block before the LN transaction is put into a block then the LN transaction would now be invalid.

Basically i don't understand how LN allows instant payment in a shop while maintaining security of that payment from the shops point of view.

I know i must be not fully understanding how this process works. Can anyone shed some light on this?
This is a very good question and I will give a quick summary of what is happening here. The longer version can be seen on my educational video on how to create payment channels starting at 33:41 (though I would recommend to watch from the beginning to review bitcoin and notation.) 


  My understanding being the multi sig wallet is a temporary address which will remain active until the LN channel is closed.


yes this is true! The key is a multi sig address which already prevents the attack setting to the shop which you discribed in the onchain bitcon setting without confirmations. If only you need a key for a double spend you can double spend. In the setting of the multisig you would need collaboration from the victim (shop) which would not do help you


  When it's closed a new transaction would be created distributing the funds to my wallet and the shop's wallet depending on where the funds were in the LN channel when the channel was closed


I think this is where you might not have the concept fully right. While it is true that the funds from the multisig wallet will be moved according to the distribution of funds to the two channel partners the initial transaction that spends those funds will be created even before the channel is opened by sending funds to the multisig from which this commitment transactions spends. 

All that being said. the funding transaction is not in the mempool as you guessed but in fact confirmed within the blockchain for the channel to be open and operational. So for an initial channel opening (unless using the somewhat special setting which allows turbochannels) one also has to wait for a couple of confirmations to use the channel safely. The setting with the shop also would not require you to have a direct channel with the shop. As soon as both you and the shop have channels connected to the network you should be able to pay the shop over a path of channels without the necessity to open another channel with the shop.