When we use the Bourbaki definition of function as a triple $(domain, codomain, graph)$, then two functions are usually defined to be equal iff their domains and graphs are equal. So equal functions can have different codomains. The problem is that the same sign "=" is used both for the the equality of functions and the "universal" equality (In ZFC, for example, the "universal" equality is defined for all sets). That is, the sign "=" is overloaded. Normally, from the context one can determine what is the intended meaning.
But there is a more serious trouble (as Vag pointed out early) with the Bourbaki definition, when a function is an element of a set. So it seems that the definition of function as a set of ordered pairs having the functional property is more preferable.

