Let's check what you were doing wrong.
$a = array();
$b = array('a', 'b'); // Count of elements is 2
for($i=0; $i<3; $i++){ // this will loop 3 times assigning 0,1,2 to $i where. You only needed 0 and 1 for an array with 2 elements
$a[] = array($b[$i] => array(1, 2, 3)); // here you are adding a new element to $a without providing key. So it becomes a numeric indexed array.
}
Solution:
for($i=0; $i<count($b); $i++){ // you could use $i<2 as well however count($b) makes your code more dynamic and result won't be affected if no of elements in $b changes.
$a[$b[$i]] =array(1, 2, 3); // you put $b[$i] as key for $a which creates an associative array
}