Let's do one question at a time here, because your code appears to be broken.
One problem is that you have a RewriteCond *after* the RewriteRule, which won't do anything to that RewriteRule. That may be a problem since I don't know what your intent was. I removed it because I do not think you need it... But I could be wrong.
That mis-placed RewriteCond would also affect any RewriteRule that you added later below it.
More importantly, you have nothing in this rule to prevent looping.
The www.robert.mydomain.th to robert.mydomain.th redirect must be being done elsewhere, because your code as shown here would not allow access using www.robert.mydomain.th. Since you say that works, there must be some other code elsewhere that is handling this.
The <IfModule> container is only needed if you
want this code to fail silently if mod_rewrite is not installed. That would make finding the problem more difficult...
I'd suggest:
ErrorDocument 404 /page_error.html
#
Options +FollowSymLinks Options +Indexes -MultiViews
RewriteEngine on
RewriteBase /
#
# Externally redirect to canonicalize all hostnames (remove extra "www", trailing FQDN
# period, port numbers, and redirect mydomain.com.th to www.mydomain.com.th
RewriteCond %{HTTP_HOST} ^www.([^.]+\.)mydomain\.com\.th [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+\.)www\.mydomain\.com\.th [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+\.)mydomain\.com\.th(\.?:[0-9]+|\.)$ [NC,OR]
RewriteCond www.%{HTTP_HOST} ^(www\.)mydomain\.com\.th [NC]
RewriteRule ^(.*)$ http://%1mydomain.com.th/$1 [R=301,L]
#
# Internally rewrite <user>.mydomain.com.th/<anything> requests to myfirstpage.php?username=<user>
RewriteConde $1 !^mypage\.php$
RewriteCond %{HTTP_HOST} !www\.mydomain\.com\.th$ [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9][a-z0-9\-]*[a-z0-9])\.mydomain\.com\.th [NC]
RewriteRule ^(.*)$ /mypage.php?username=%1 [L]
With this code, your "mypage.php" script must examine the server variables to get the requested page or object URL-path, because your rewrite rule does not forward the requested resource URL-path to your script.
For example, how do you plan to handle a request for "robert.mydomain.com.th/roberts-logo.gif" or "robert.mydomain.com.th/styles.css"? What about "robert.mydomain.com.th/robots.txt"?
An alternative would be to pass the "requested object" to your script as well, for example, by changing the rule to:
RewriteRule ^(.*)$ /mypage.php?username=%1&rqstobj=$1 [L]
and modifying your script to accept the rqstobj query parameter.
Jim