There are often different reasons why the male dog marks indoors and it usually happens in a new place where the dog has not been before. Often this is because the dog wants to put its scent on the surroundings, in other words, they want to mark their territory. If the dog is visiting another dog's home, it will be natural for the dog to want to mark.
If you have a dog that marks indoors when you are visiting other houses - have your dog on a leash. This way you have full control over your dog, and you also have the chance to correct your dog before an accident has occurred. If you notice that the dog is about to mark - say "No!" calmly but firmly and remove the dog from the place. If the dog has already marked then you should not get angry as the dog will not understand why.
If the dog has urine marked a spot then it is important that the smells are washed away properly, otherwise the risk is very high that the dog will mark at the same place again. There are repellent sprays that remove and neutralize the smells if an accident has occurred. If the dog continues to mark, there are male dog wraps that you can use.