First of all, it should be clear that marriage, in Islam, is a solemn contract for which the Shari`ah lays down rules and arrangements to guarantee its stability.
Coming to the point you raised in your question, you are to keep in mind the fact that valid marriage has to meet certain requirements such as Ishhar (announcement), the payment of the dower, the consent of both parties, the permission of the Wali (girl’s guardian), and the presence of witnesses.
Az-Zuhri says that the announcement of marriage is obligatory. If two people get married secretly
with two witnesses and ask them to keep it secret, they should be separated immediately.
There are a number of Hadiths on this topic and all of them are Hasan. For example, the Prophet, peace and blessings be upon him, said, “Make the marriage well-known and announce it.”
The eminent Muslim scholar, Sheikh `Abdel Khaliq Hasan Ash-Shareef, the renowned Da`iyah, states: “marriage should meet certain conditions in order to be valid. There should be consent from both the parties, presence of witnesses, payment of dower, permission of Wali in case of virgin girl, and Ishhar.
Ishhar means that marriage should not be concealed. Neighbors, friends, relatives, etc. have to know about it. Witnesses are not sufficient to meet such a condition.
In short, a valid marriage should be publicized so that it’s not concealed or kept in secret.”