my question is:
why does broadcasting work when I use element-wise multiplication "*" but when I use dot product it produces an error?
Note: my question is regarding the broadcasting (regardless of the correctness of the output)
any help would be appreciated.

Maybe I’m confused, but I think this has nothing to do with broadcasting.

Element-wise products require that the shapes of the two operands be identical. (5,10) * (5,10) works fine. Note that it doesn’t include computing the sum of the products.

Using a dot product requires that the inner dimensions of the operands be the same. So (5, 10) dot (5,10) will give an error. You would have to transpose the second operand so you have (5, 10) dot (10, 5). And the dot product will also compute the sum of the products.

Tom has addressed the particular situation you showed. The general answer is that the definition of broadcasting is that it can expand a vector to match the size of a matrix for an operation that requires two operands of the same shape. So it only applies to “elementwise” operations. Of course that covers other elementwise operations besides just multiplication. That is what broadcasting is for, so it is not relevant to the dot product case, because that (by definition) is not about operands with the same shape.