Because buttercream is an emulsion like cream or mayonnaise, it sometimes separates while you are beating it. This is especially true if you are beating cold buttercream you’ve saved in the refrigerator or freezer.
If buttercream separates and starts to look grainy after you’ve added all the butter and flavoring, beat a little longer—5 minutes or so—to see if it comes together on its own. If it still won’t smooth out, put the bowl over a very low flame (provided the bowl is metal) or over a saucepan of simmering water for about 20 seconds and beat again for 5 minutes. You may have to do this once or twice to get it to work.