When I run this query in SQL Server
SELECT custid AAA, companyname AAA
FROM Sales.Customers
WHERE country = \'USA\'
It\'s running fine. But
Reason for this problem is:
1st Query
SELECT custid AAA, companyname AAA
FROM Sales.Customers
WHERE country = 'USA'
Here, you are assigning column alias at the time of output, so AAA is as column name(alias actually) attached at the time of returning result, but i guess you will see only 1st column with AAA other will be removed because of possible confliction during further reference. so here you are not getting error.
SELECT * FROM (
SELECT custid AAA, companyname AAA
FROM Sales.Customers
WHERE country = 'USA') BBB
Here you got error because, you are selecting records from Inline View with name BBB, here that Inner Query(inline view) is considered as a Table(for your SELECT * FROM statement), and as we know - basically Table can not have multiple same column name, because of that you are getting error that BBB has multiple AAA column.