You have almost answered your own question: The context/intended meaning in combination with the type of verb determines which preposition is used.
To struggle has two meanings
(i) to have severe difficulties (because of something) - "He struggled to stand up when he broke his leg/because of his broken leg/with his broken leg.
(ii) to fight for or against something "He struggled for political freedom and against oppression."
against carries the idea of "in opposition to";
with carries the idea of (i) "when attended by" or (ii) "under the simultaneous influence of" or because of but it can mean (iii) "in the company of."
Thus "I fought with my brother" can mean (i) you and your brother fought each other, or (ii) you and your brother fought together against a common enemy.
Many families are struggling against poverty and hunger. This indicates that the families are opposing poverty in principle, although they themselves are not necessarily poor.
Many families are struggling with poverty and hunger. can mean "in difficulties because of poverty" or are actively fighting against poverty (e.g. protesting against poverty)
Struggle: 1.a. intransitive. To contend (with an adversary) in a close grapple as in wrestling; also, in wider use, to make violent bodily movements in order to resist force or free oneself from constraint; to exert one's physical strength in persistent striving against an opposing force.
1856 E. K. Kane Arctic Explor. II. xv. 165 We struggled manfully to force our way through.
1905 E. Glyn Vicissitudes Evangeline 222 ‘No, no’, I said, struggling feebly to free myself.
2. a. figurative. To contend resolutely, esp. with an adversary of superior power; to offer obstinate resistance; to make violent efforts to escape from constraint. Constructed using with, against, for
1642 T. Fuller Holy State v. vi. 381 With these and other arguments he struggles with his own conscience.
1855 C. Kingsley Sir W. Raleigh in Misc. (1860) I. 14 Close to our own shores, the Netherlands are struggling vainly for their liberties.
1856 Ann. Reg., Chron. 65/1 The counsel for the prisoner attempted to struggle against both the evidence and the prisoner's statement.
Against: II. Expressing motion or action in opposition to someone or something.
2. a. In active hostility or opposition to; so as to fight with or attack (verbally or physically).
1849 T. B. Macaulay Hist. Eng. II. 205 The whole Cavalier gentry were against him.
1849 T. B. Macaulay Hist. Eng. II. 37 The members who had voted against the court were dismissed.
With: 39. a. Indicating the cause or reason: In consequence of, as a result of, by the action of; because of, by reason of, on account of; from, through, by.
1816 Ld. Byron Prisoner of Chillon 1 My hair is grey, but not with years.
1837 N. Hawthorne Great Carbuncle in Twice-told Tales The..branches..mossy with age.