First of all, ^ matches the beginning of the string. ~^www.amazon.com will match www.amazon.com but not 1www.amazon.com or a.www.amazon.com. Remember on pcWRT router, the dot without a leading \ matches the dot itself (unlike the standard regex, which matches any single character).
^(www.)?amazon.com matches both www.amazon.com and amazon.com (i.e., the grouping with a question mark matches the group 0 or 1 times).
~^www.amazon.\.* matches anything starting with www.amazon., e.g., www.amazon.com, www.amazon.us, www.amazon.eu etc.
~^(www\.)?amazon\.: the \ preceding the dot changes the meaning of the dot to match any single character. So this regex will match amazon.com, amazon-with-anything-else-here, because there is no end of string anchor $. Apparently, you want the dot to be a literal match here. Thus the correct regex should be: ~^(www.)?amazon., which would match amazon.anything-here, www.amazon.anything-here. But it would not match www.amazonaws.com, because a dot must follow amazon, not an a (in aws).