I can’t reproduce this, probably you have attached a docstring to something else called f in that same Julia session.
Note also that if you just want to attach the docstring to a function rather than a method you can do
"""
doc of f
"""
function f end
f(m::AbstractMatrix) = g(m)
f(r::AbstractVector) = g(h(r))
for example.