We usually surround nonrestrictive / parenthetical phrases with paired commas. However, whether a phrase meets that condition is often quite debatable. When a phrase follows a verb that it modifies, we usually don't use commas unless that phrase is clearly nonrestrictive / parenthetical. Therefore:
Without commas, "as" and "like" would normally mean "in the same way as" (your meaning #1).
My sister played the violin as my brother did.
My sister played the violin like my brother (did).
(Some people might write these sentences intending the other meaning.)
With commas, "as" and "like" would almost certainly mean that the brother played the violin, too (your meaning #2).
My sister played the violin, as my brother did.
My sister played the violin, like my brother (did).
(The second comma disappears because it is next to the period.)
(It's very unlikely that someone would write these sentences intending the other meaning.)