The question about homology is answered by Eric.
The question of obtaining a homotopy equivalence of pairs assuming $A \to X, B \to Y$ are cofibrations is answered by 7.4.2 of Topology and Groupoids,(T&G), and the Addendum to that result shows how the homotopy inverse to $f$, and the homotopies, may be constructed from the given data. That answers your question on $g$. Here is a slightly transliteratwed version of that Addendum_:
Let $g^{0} :
B \to A$ be any homotopy inverse of $f^{0}:A \to B$ and let
$H^{0}_{t} : f^{0}g^{0} \simeq 1$, $K^{0}_{t} : g^{0}f^{0} \simeq 1$
be homotopies. Then $g^{0}$ extends to a homotopy inverse $g':Y \to X$ of
$f$ such that the homotopy $fg'\simeq 1$ extends $H^{0}_{t}$ while
the homotopy $g'f\simeq 1$ extends the sum
$$
K^{0} + g^{0}H^{0}f^{0} - g^{0}f^{0}K^{0}
$$
of the homotopies
$$
g^{0}f^{0} = g^{0}f^{0}1_{A} \simeq g^{0}f^{0}g^{0}f^{0}
\simeq g^{0}1_{B}f^{0} \simeq 1_{A}
$$
determined by $H^{0}_{t}$ and $K^{0}_{t}$.
I do not know of examples showing that the description of the homotopies cannot be simplified. However the explicit form has useful implications, for example if $H,K$ are constant homotopies, and also to a gluing theorem (7.4.3 of T&G). It is not clear if $g'$ is homotopic to $g$.
These results were found in the 1960s by generalising the well known result that a homotopy equivalence $f: X \to Y$ induces an isomorphism of homotopy groups $\pi_n(X,x) \to \pi_n(Y, f(x))$. That proof involves an operation of fundamental groups on homotopy groups, so the more general result uses a more general operation, as in T&G, compare Section 5.2 of tom Dieck's "Algebraic Topology".