It's not like Nintendo took legal action for the Mario stages though, they just did that themselves.
However, the difference here is that this is a TF2 homage, and there's no way to truly recreate TF2 in LBP. Technically, a Mario-themed stage would be ok, but their problem was with stages that were direct recreations of World 1-1. Given the amount of people who just directly recreated iconic Mario stages, they just purge(d) all Mario levels to save time rather than pick through and see which stages aren't problematic, and afterwards they made a blanket statement regarding "copyrighted material" to cover themselves without having to get into the specifics.