Can students finish much of their PhD thesis before applying to a PhD program? Are students allowed to complete a large portion of their research independently, then enroll in a PhD program, apply for a defense panel within the first semester, and quickly finish the thesis? Has this been done before?

Update: Question trimmed. I'm looking for an answer whether students can be admitted with much prior work on the thesis already complete, to finish in a short time (perhaps one year fix and improve the work), and whether there are real examples of people who did this. I not asking whether I myself am personally capable of completing this prior work to sufficient quality.
I can't speak to whether this is possible, but I can advise as to why I think it's a bad idea.

Firstly, PhD Comics is a largely satirical and humourous representation of life in academia. Some of those comics can be scarily true, but you can probably find a comic that parodies any job you care to imagine. It doesn't mean they all suck.

Even if you could do this, for most people and disciplines it's not a good way to get a PhD. You really should find an advisor to help you guide your research. Colleagues are great to bounce ideas off of. Having an office to work in and access to a good library is a huge advantage. You will have access to high-performance computing and lab facilities, if needed. If you're lucky, you'll find someone to pay you to do your research.

At the end, you will graduate being well-absorbed into academic life. You'll have networking skills, have been to and presented at conferences, your research will be of a higher quality, and you will overall be a much more well-rounded and knowledgeable researcher than had you stuck at it alone. The skills you learn as a PhD student are essential if you wish to have a career in academia. If you wish to go on into an industry job, they're still pretty darn useful.