For the first example, see if you can substitute a 'which' phrase for the gerund. In the first example, it would look like this:
'Hungary has passed laws which make it a crime to hel undocumented migrants and set up a new parallel legal system.'
This property tells you that the first example's gerunds are adding additional information about what Hungary's laws do, almost like an adjective, but in phrase form.
Commas are legal before the first gerund in both examples ( '... laws, making...' and '... mode, beginning...').
In the second example, though, the sentence would appear more coherent if it was phrased this way:
'Consular officials are shifting into crisis mode and are beginning to search for children as young as nine months old, who did not appear to have been carefully tracked by the federal authorities.'
For more on the second example, Google 'parallel structure'.