the Line,
feature = layer.selectedFeatures()
returns a list of QgsFeature. You will need to loop over it to process individual selections.
If you only have one feature selected in map, then
geom = feature[0].geometry()
mbuf = geom.buffer(50, 2)
might work.