I want to know, what happens when we connect the 5V GPIO output with the Ground of the GPIO, and why the RPi restarts. Also if it's possible, I want to know what's the Technical Explanation for this issue.
when you connect output GPIO to the ground, the poor CPU tries to keep the +5V on that pin as hard as it might, but fails, resulting in huge current leak, and the CPU restarts because of the low voltage.
if you use bigger and stronger power supply, you may get rid of the restarts, but it might result in your CPU burned to the ground, so I don't recommend that.
and, yeah, connecting output pin directly to the ground is not a very bright idea to begin with.
it may be a little unrelated since i have an Orange Pi PC, but i'm writing this since it may happen for a lot of other people. after doing exactly what you did GPIO pins 2 and 6, my Power Regulator burned and I got really scared, I thought i burned the CPU and also because be board wasn't mine! :D i got everything working again by replacing the Power Regulator with a New one. so try this as well. :)