Is it possible to learn to swim from watching YouTube videos?
Yes and no.
You can learn the theory of how to float, breathe and move in the water through watching videos online.
However to put it into practice and to really master it, you would need to be in the water! Learning to swim as an adult requires more co-ordination than people realise. It would of course be even more beneficial to be assessed and corrected under the guidance of a swimming instructor, so you can be coached on your weak areas and most importantly, avoid developing bad technique.