Think about what happens in your code if nargin == 1. In that case, b does not exist, but you get into the nargin<3 test and try to use b. So this will fail.
Your words are not entirely clear to me, but here is a guess at what you might want:
function replace(a,b,c)
if nargin < 2
a = 0;
b = 0;
c = 0;
elseif nargin < 3
a = b;
c = 0;
end
2nd attempt at coding verbatim what you requested:
function replace(a,b,c)
if nargin < 2
a = [0 0];
elseif nargin < 3
a = [b b];
end