Why are some items in the array being skipped?

I have a table

table

I have the following script

$Result = Query "SELECT [databasename], [servertypeA], [servertypeB] from table GROUP BY [databasename], [servertypeA], [servertypeB]"

$Servers = @()
$DB = @()

foreach($row in $Result)
{   
    $i++
    $DB += $row.Item("databasename")
    $Servers += $row.Item("servertypeA")
    $Servers += $row.Item("servertypeB")

    cmd /c "PS.bat $somescript.ps1 $($Servers[-1]) $($DB[-1])"
}

this results in:

db1 serverx
db1 servery
db2 serverx
db2 servery

it should be

db1 server1
db1 serverx
db1 servery
db2 server2
db2 serverx
db2 servery

why is servertypeA being skipped, i.e. server1 and server2 in $Server?

I also tried this

$Result = Query "SELECT distinct [databasename], [servertypeA], [servertypeB] from table"

and its generating the same result

The answer is here: https://stackoverflow.com/a/55228922/8397835

$Result = Query "SELECT DISTINCT [databasename], [serverTypeA] As Server from table  UNION SELECT DISTINCT [databasename], [serverTypeB] from table"

foreach($row in $Result)
{   
    $DB = $row.Item("databasename")
    $Server = $row.Item("Server")

    cmd /c "PS.bat $somescript.ps1 $Server $DB"
}