(Does the first mean "(approx) My teacher told me to make a cake, so I did it " and the second "(approx)I made the cake the way my teacher told me to." ?)
The two sentences both can mean "I made the cake in the way my teacher told me." and "As my teacher said, I made the cake(My teacher said that I made the cake)." 先生がおっしゃった通りに can't have the latter meaning, though.