library(dplyr)
data2 = data %>%
mutate(type1 = recode(type1, "aa" = "", "aaa" = ""),
type2 = recode(type2, "aa" = "", "aaa" = ""))
attr type1 type2
1 1
2 2 b
3 3
4 4 b
if you wanna generalize, taking from @denis answer:
data2 = data %>%
mutate_all(function(x) gsub("aa|aaa","",x))