The physics of double layers and their role in astrophysics