united-states
Short Answer
The husband of the mother is the legal father in this case. Assuming that he is not otherwise an unfit father, the maternal grandparents have a decent chance of securing limited regular visits with their grandchildren, but not primary custody.
The maternal grandparents would ordinarily have standing to claim more than limited visitation only when the children are left with them and the children are not physically either either the husband or the mother, or when the children recently lived with the maternal grandparents away from either the husband or the mother for an extended period of time.
If there was a contest at all, because the husband's status as legal father had not yet become incontestable (typically after one to five years from birth, depending upon the state), the custody fight would be between the husband and the genetic father. If the husband's status as legal father is incontestable, or is not raised in the divorce by someone with standing to do so (typically the mother or a guardian-ad-litem for the children), then the husband's lack of genetic relationship is irrelevant.
Absent a total termination of the mother's parental rights, however, either legally, or due to death, the mother will usually have some visitation to the extent feasible, and some say in making major decisions for her children to the extent feasible.
Long Answer
To the best of my limited awareness, in a normal divorce, a mother has
a good chance to win custody if the father isn't biologically related
to the kids; but here it's not the mother but mother's side
grandparents.
This is true only when the husband wasn't married to the mother at the time the children were born, isn't listed on the birth certificate of the children, and isn't otherwise presumed by law to be the parent of the child. Paternity isn't entirely a matter of genetic parentage. The legal presumption of paternity in a married couple is very strong.
This is purely a matter of state law which is not precisely the same in every U.S. state, commonwealth, territory, or district.
In the fact pattern of the question, the husband of the mother is the legal parent of the children. The details of this analysis are explored, for example, in this Law.SE question.
The maternal grandparents are not (assuming that there is no instance of incestuous parenting).
So, unless the children have been living with the maternal grandparents for an extended period of time, or the children are living with the maternal grandparents at the time of the divorce, the maternal grandparents may not even have standing to ask for more than grandparent visitation.
Custody is only allocated in the best interests of the child among people who have standing to seek it.
For example, in Colorado, standing to participate in parenting decisions is governed by Colorado Revised Statutes § 14-10-123, which states (omitting provisions related to automatic restraining orders and procedural issues imposed in these cases):
(1) A proceeding concerning the allocation of parental
responsibilities is commenced in the district court or as otherwise
provided by law:
(a) By a parent:
(I) By filing a petition for dissolution or legal separation;  or
(II) By filing a petition seeking the allocation of parental
responsibilities with respect to a child in the county where the child
is permanently resident or where the child is found;  or
(b) By a person other than a parent, by filing a petition seeking the
allocation of parental responsibilities for the child in the county
where the child is permanently resident or where the child is found,
but only if the child is not in the physical care of one of the
child's parents;
(c) By a person other than a parent who has had the physical care of a
child for a period of one hundred eighty-two days or more, if such
action is commenced within one hundred eighty-two days after the
termination of such physical care;  or
(d) By a parent or person other than a parent who has been granted
custody of a child or who has been allocated parental responsibilities
through a juvenile court order entered pursuant to section
19-1-104(6), C.R.S., by filing a certified copy of the juvenile court
order in the county where the child is permanently resident. Such
order shall be treated in the district court as any other decree
issued in a proceeding concerning the allocation of parental
responsibilities.
(1.3) As used in this section, excluding subsection (1.5) of this
section:
(a) “Child” has the same meaning as set forth in section 19-1-103(18).
(b) “Parent” has the same meaning as set forth in section
19-1-103(82)(a).
(1.5)(a) For purposes of this subsection (1.5) only, “child” means an
unmarried individual who has not attained twenty-one years of age.
(b) The court may enter an order for allocation of parental
responsibilities for a child, as defined in subsection (1.5)(a) of
this section, and a determination of whether the child shall be
reunified with a parent or parents, when the requirements of
subsection (1) of this section are met, the order is in the child's
best interests, and:
(I) The child has not attained twenty-one years of age;
(II) The child is residing with and dependent upon a caregiver;  and
(III) A request is made for findings from the court to establish the
child's eligibility for classification as a special immigrant juvenile
pursuant to 8 U.S.C. sec. 1101(a)(27)(J).
(c) If a request is made for findings from the court to establish the
child's eligibility for classification as a special immigrant juvenile
under federal law and the court determines that there is sufficient
evidence to support the findings, the court shall enter an order,
including factual findings and conclusions of law, determining that:
(I) The child has been placed under the custody of an individual
appointed by the court pursuant to an order for allocation of parental
responsibilities;
(II) Reunification of the child with one or both parents is not viable
due to abuse, neglect, abandonment, or a similar basis found under
state law;  and
(III) It is not in the best interests of the child to be returned to
the child's or parents' previous country of nationality or country of
last habitual residence.
(1.8) The court shall make all necessary persons parties to the
proceeding pursuant to the requirements of section 19-4-110 and shall
make a determination pursuant to section 19-4-105 as to legal
parentage.
(2) Except for a proceeding concerning the allocation of parental
responsibilities commenced pursuant to paragraph (d) of subsection (1)
of this section, notice of a proceeding concerning the allocation of
parental responsibilities shall be given to the child's parent,
guardian, and custodian or person allocated parental responsibilities,
who may appear and be heard and may file a responsive pleading. The
court may, upon a showing of good cause, permit the intervention of
other interested parties.
In the Colorado example, limited grandparent visitation can be allowed, however, even when grandparents can't be granted primary custody or decision-making authority:
According to Colorado law (C.R.S. §19-1-117), grandparents’ will
have the right to request visitation of grandchildren when:
- The grandchild’s parents have divorced, have had their marriage annulled or have legally separated. 
- Someone other than a parent of the child has been given custody of the child. 
- One parent of the child may have passed away. 
If, in such situations, the court deems that it is in a child’s best
interests to have regular visits with his or her grandparents, then
this visitation may be ordered. In other words, while grandparents may
have the right to request visitation with a grandchild, they do not
necessarily always have the legal right to be granted visitation.
Requests by grandparents for custody in Colorado (either full custody if they have standing as non-parents to ask for it, or limited visitation requests), as a continuing example, are also subject to Colorado Revised Statutes § 14-10-123.3 which states:
Whenever a grandparent seeks parental responsibility for his or her
grandchild pursuant to the provisions of this article, the court
entering such order shall consider any credible evidence of the
grandparent's past conduct of child abuse or neglect. Such evidence
may include, but shall not be limited to, medical records, school
records, police reports, information contained in records and reports
of child abuse or neglect, and court records received by the court
pursuant to section 19-1-307(2)(f), C.R.S.
In most U.S. states, there is a limited time period, often one to five years after a child is born, after which the father's legally established paternity is incontestable for custody and child support purposes by anyone, regardless of the genetic parentage of the child. So the age of the children would be highly relevant.
For example, if the child or children are 6-7 years old, as suggested in a comment, then the paternity of the mother's husband is incontestable, and the lack of a genetic parental relationship is completely irrelevant.
In many U.S. states (perhaps most), the genetic father of the children has no standing to seek to be determined to be the father of a child born to a married woman. So, if neither the father nor the mother nor a guardian-ad-litem for the children contested paternity in the divorce, the birth certificates would be controlling. In this situation, the husband of the mother wouldn't seek to contest paternity, and it would be unusual but not unheard of, for a guardian-ad-litem to be appointed in a plain vanilla divorce with children young enough to have contestable paternity. So, in those states, if the mother didn't raise the issue, the husband's status as legal father would usually be uncontested.
If the mother raised the issue in the divorce and the children were not too old for her husband's paternity to be incontestable, the custody fight would be between the genetic father and the the husband,  not between the maternal parents and the husband. A custody fight between the genetic father and the husband would be decided in the best interests of the children, but would favor the husband if the children had spent several years of their lives with him (e.g. 2.5 and 4.5 years).
Generally speaking, the genetic father's chances of winning would be enhanced if (1) the children were younger, (2) the genetic father had been a part of the children's life in some way (e.g. a live-in, non-incestuous, extended family member such as a paternal uncle of the children who lived in the same household), and/or (3) if the genetic father was in a better position economically to be a parent and/or just was better at parenting than the husband of the mother.
For example, the primary child custody statute in Colorado that applies in divorce cases, Colorado Revised Statutes § 14-10-124 (omitting provisions related to abuse, neglect, rape, domestic violence, for which special rules apply and also omitting repealed subsections, and procedural matters) reads as follows:
(1) Legislative declaration. While co-parenting is not appropriate in
all circumstances following dissolution of marriage or legal
separation, the general assembly finds and declares that, in most
circumstances, it is in the best interest of all parties to encourage
frequent and continuing contact between each parent and the minor
children of the marriage after the parents have separated or dissolved
their marriage. In order to effectuate this goal when appropriate, the
general assembly urges parents to share the rights and
responsibilities of child-rearing and to encourage the love,
affection, and contact between the children and the parents.
(1.3) Definitions. For purposes of this section and section
14-10-129(2)(c), unless the context requires otherwise . . .
(1.5) Allocation of parental responsibilities. The court shall
determine the allocation of parental responsibilities, including
parenting time and decision-making responsibilities, in accordance
with the best interests of the child giving paramount consideration to
the child's safety and the physical, mental, and emotional conditions
and needs of the child as follows:
(a) Determination of parenting time. The court, upon the motion of
either party or upon its own motion, may make provisions for parenting
time that the court finds are in the best interests of the child, with
the child’s safety always paramount, unless the court finds, after a
hearing, that parenting time by the party would endanger the child’s
physical health or significantly impair the child’s emotional
development. In addition to a finding that parenting time would
endanger the child’s physical health or significantly impair the
child’s emotional development, in any order imposing or continuing a
parenting time restriction, the court shall enumerate the specific
factual findings supporting the restriction . . .  and may enumerate
the conditions that the restricted party could fulfill in order to
seek modification in the parenting plan. . . . In determining the best
interests of the child for purposes of parenting time, the court shall
consider all relevant factors, including:
(I) The wishes of the child's parents as to parenting time;
(II) The wishes of the child if he or she is sufficiently mature to
express reasoned and independent preferences as to the parenting time
schedule;
(III) The interaction and interrelationship of the child with his or
her parents, his or her siblings, and any other person who may
significantly affect the child's best interests; . . .
(IV) The child's adjustment to his or her home, school, and community;
(V) The mental and physical health of all individuals involved, except
that a disability alone shall not be a basis to deny or restrict
parenting time;
(VI) The ability of the parties to encourage the sharing of love,
affection, and contact between the child and the other party; . . .
(VII) Whether the past pattern of involvement of the parties with the
child reflects a system of values, time commitment, and mutual
support;
(VIII) The physical proximity of the parties to each other as this
relates to the practical considerations of parenting time; . . .
(XI) The ability of each party to place the needs of the child ahead
of his or her own needs.
(b) Allocation of decision-making responsibility. The court, upon the
motion of either party or its own motion, shall allocate the
decision-making responsibilities between the parties based upon the
best interests of the child. In determining decision-making
responsibility, the court may allocate the decision-making
responsibility with respect to each issue affecting the child mutually
between both parties or individually to one or the other party or any
combination thereof. . . . In determining the best interests of the
child for purposes of allocating decision-making responsibilities, the
court shall consider, in addition to the factors set forth in
paragraph (a) of this subsection (1.5), all relevant factors
including:
(I) Credible evidence of the ability of the parties to cooperate and
to make decisions jointly;
(II) Whether the past pattern of involvement of the parties with the
child reflects a system of values, time commitment, and mutual support
that would indicate an ability as mutual decision makers to provide a
positive and nourishing relationship with the child;
(III) Whether an allocation of mutual decision-making responsibility
on any one or a number of issues will promote more frequent or
continuing contact between the child and each of the parties. . . .
(1.7) Pursuant to section 14-10-123.4, children have the right to have
the determination of matters relating to parental responsibilities
based upon the best interests of the child. In contested hearings on
final orders regarding the allocation of parental responsibilities,
the court shall make findings on the record concerning the factors the
court considered and the reasons why the allocation of parental
responsibilities is in the best interests of the child.
(2) The court shall not consider conduct of a party that does not
affect that party's relationship to the child.
(3) In determining parenting time or decision-making responsibilities,
the court shall not presume that any person is better able to serve
the best interests of the child because of that person's sex.
(3.5) A request by either party for genetic testing shall not
prejudice the requesting party in the allocation of parental
responsibilities pursuant to subsection (1.5) of this section. . . .
(6) In the event of a medical emergency, either party shall be allowed
to obtain necessary medical treatment for the minor child or children
without being in violation of the order allocating decision-making
responsibility or in contempt of court.
(7) In order to implement an order allocating parental
responsibilities, both parties may submit a parenting plan or plans
for the court's approval that shall address both parenting time and
the allocation of decision-making responsibilities. If no parenting
plan is submitted or if the court does not approve a submitted
parenting plan, the court, on its own motion, shall formulate a
parenting plan that shall address parenting time and the allocation of
decision-making responsibilities. When issues relating to parenting
time are contested, and in other cases where appropriate, the
parenting plan must be as specific as possible to clearly address the
needs of the family as well as the current and future needs of the
aging child. In general, the parenting plan may include, but is not
limited to, the following provisions:
(a) A designation of the type of decision-making awarded;
(b) A practical schedule of parenting time for the child, including
holidays and school vacations;
(c) A procedure for the exchanges of the child for parenting time,
including the location of the exchanges and the party or parties
responsible for the child's transportation;
(d) A procedure for communicating with each other about the child,
including methods for communicating and frequency of communication;
(e) A procedure for communication between a parent and the child
outside of that parent's parenting time, including methods for
communicating and frequency of communication;  and
(f) Any other orders in the best interests of the child. . . .
Special rules often apply to parents on military deployments.
So, most of the time, the legal father of the child, i.e. the husband of the mother, would get custody of the children if the mother was completely incapable of having custody due to death, or being an a coma expected to be of an extended duration, or if the parental rights of the mother were legally terminated (e.g. for child abuse or child neglect).
Even if the mother was incapable of living with the children part of the time, however, due to incarceration, or being stuck on a space station, or having to work someplace where the children couldn't be (e.g., if the mother were stationed in a forward operating based in a war zone as a soldier), the mother could usually exercise some joint decision-making authority over the children with the ex-husband if that was feasible given their interaction with each other. Also, keep in mind that custody decisions are not permanent. They can be revisited when there is a substantial change in circumstances, such as a mother's release from prison or return from a foreign military deployment.