This depends on whether you are related by blood within three generations.
Like my parents, they are from the same village. When I used to go home to visit relatives, it only took ten minutes to walk from my grandpa’s house to my grandpa’s house.
There is also my aunt and my uncle. They are from the same village and have the same surname. Both of them have the surname Chen. They can also get married.
People from the same village and the same surname can get married no matter where they are as long as there is no blood relationship or legal relationship.