Mac’s brightness is set to automatically dim and adjust the brightness in different situations. This is however very annoying sometimes when having multiple external screen connected, then the mac screen will dim itself.
To remove this unwanted feature go to the System Preferences -> Display. Here untick “Automatically adjust brightness”.
Set the brightness level you desire without the mac automatically adjusting it in the future.