You CAN buy a home OR sell a home while not in the actual state where the property is.
If you are looking to buy a home out of state, I highly recommend at least coming into town once to see available homes in person. Once that is done, however, the rest can be done without being present.
Whether buying or selling a home, there are a number of items that can be filled out electronically with e-signatures. There are a few that are required to be wet signed, which means everything is printed, signed with a pen, scanned, and then emailed in. You have the option of using a mobile notary, where someone will come to you and notarize your documents as you sign them. You also have the option of printing everything, taking it all to the bank, and then signing and notarizing the documents there before mailing them.
If you are looking to buy or sell real estate out of state, make sure there is good communication between all parties and that you are clear about how you will be exchanging documents, as some of these processes require extra time.
Want specific tips for your unique situation? Feel free to contact me!