The critical factor is who is on title to the property. I assume you are asking about the primary residence, and that the spouse who would "buy" would require financing. A simple title search will show both spouses as owners, or if the proprty was acquired prior to marriage, the search would show the other spouse.
Two factors create the problem: First, one spouse buying from another constitutes a non-arms length transaction, which introduces many restrictions on lending guidelines. Second, the current lender would never approve such a sale since the purchasing spouse is already a vested owner of the property.