Custom Taxonomy List with Children

Your code works perfectly in a custom taxonomy template file.

CASE 1

You’re trying to use this code in a single page or something else and it doesn’t work because the object returned from get_queried_object() isn’t a taxonomy.
The function get_queried_object() return the currently-queried object.
So, if you need a Taxonomy Object you have to call it in a taxonomy archive page.

CASE 2

You’re using this code in a taxonomy archive page.
If you need to display the same list for parents and childrens you have to check if the current term is a children or a parent, because you have to call get_term_children() with the parent id as argument.

If you call get_term_children() with the current term ID on the children you’ll probably get an empty list.

So check $term->parent value.
This variable outputs the ID of the parent taxonomy. So if you are on the parent taxonomy, then $term->parent will echo 0 and you can call get_term_children() with the $term->term_id value.
If you are on a children you have to call get_term_children() with the $term->parent value.