When I run this query in SQL Server
SELECT custid AAA, companyname AAA
FROM Sales.Customers
WHERE country = \'USA\'
It\'s running fine. But
This can be explained by understanding order of execution of different logical phases of query execution. Query Execution Order MSDN
In SQL Server the order is FROM > WHERE > SELECT i.e. first FROM clause is executed then WHERE clause and last is the SELECT list.
Now in your first query , all matching rows from table Sales.Customers are fetched and then then afterwards columns specified in SELECT list are pulled out and then Alias names are applied.
In your second query , the inner query is executed successfully as the first query but when the outer query's FROM clause tries to fetch columns from resultset returned by inner query , it finds duplicate columns and throws error.