The ghost town was the set for The Andy Griffith Show (1960) with several buildings routinely shown from downtown Mayberry. One of the crew members was even banging on Andy's front door.
The set was also later used for the short lived The New People (1969). Interestingly, in one scene the castaways encounter a mannequin, which was part of the plot device for that show.
This episode is very similar to Stopover in a Quiet Town (1964). In it, a couple wake up to find themselves in a deserted town that is like a movie set. They discover that they've been abducted by a giant alien and are now "pets" of a giant child.
This is Production number 2414. It was the 14th to be produced, but the second to be broadcast.