Question 1. While doing namasmarana with mouth if another worldly thought comes into our mind then does that namasmarana gets counted?
To my limited knowledge, I think we'd be hard pressed to find explicit references on this in the scriptures.
However, Swami Ramsukhdasa does attest the significance of "name-chanting" upto a particular number, to experience the physical manifestation of our ishta deity.
This is what he says in his work - GitA-DarpaNa (page 76), I'm summarising his opinion by self translating from the original Hindi work-
Question - In the shastras, and also as said by several saints & sages, that doing
the naam-japa of a particular deity for a particular counting bestows
on the chanter the vision of the deity, Is this true?
Swami Ramasukhdasa answers -
Chanting the Hare Krishna Mantra for 3.5 crore times yields the vision of the God. This has been mentioned in the Kalisantarana
Also, chanting the name of Rama, 13 crore times, yields his divine forms' vision. This has been written by Samarth Ramadasa Baba in his
However, if one has complete, unequivocal faith in the name and
substance of the God and his glory, the revelation of his divine form
may occur earlier than the prescribed japa numbers.
Question 2. - While doing namasmarana with mouth if another worldly thought comes into our mind then does that namasmarana gets counted?
Yes, it does count.
Although, there might be more advantages of contemplating with complete concentration, but even without concentration, the japa of God's name is beneficial, no doubt about it.
In his book, Japa, Sri Swami Sivananda observes
The Name of God, chanted correctly or incorrectly, knowingly or
unknowingly, carefully, is sure to give the desired result. Just as
burning quality is natural to and inherent in fire, so also, the power
of destroying sins with their very root and branch, and bringing the
aspirant into blissful union with the Lord through Bhava-Samadhi, is
natural to and inherent in the Name of God.
The glory of the Name of God cannot be established through reasoning
and intellect. It can be experienced or realized only through
devotion, faith and constant repetition of the Name.
In fact, the famous Vishnu Mantra which is generally recited in the beginning of religious rites itself confirms the above idea, even so indirectly though, perhaps.
अपवित्रः पवित्रो वा सर्वावस्थां गतोऽपि वा ।
यः स्मरेत्पुण्डरीकाक्षं स
बाह्याभ्यन्तरः शुचिः ॥ १,२१७.१ ॥
Be one may be impure or pure, or even in any other conditions. He who
remembers Pundarikaksha (the one with the Lotus-like Eyes), they
become Pure outwardly as well as inwardly.
Garuda Purana 1.217.1
Note that, this same Shloka is found in multiple texts like Brahmavaivarta Purana (1.27.27), et al.
As per words of saints atleast, doing mantra japa of Sri Rama, 13 crore times, yields his divine forms' vision. Similarly, if faith and belief is strong we can experience the divine revelation of any deity earlier than the prescribed number of japa.
Doing namasmarana with mouth, if another worldly thought comes into our mind then that namasmarana also gets counted. Although, the effect maybe less, but it does count.