On functorial (co)localization of algebras and modules over operads