This is a feature of global minor modes.
define-minor-mode declares a default custom1 :set value for the mode variable like so:
(unless set (setq set '(:set #'custom-set-minor-mode)))
That function is:
(defun custom-set-minor-mode (variable value)
":set function for minor mode variables.
Normally, this sets the default value of VARIABLE to nil if VALUE
Emacs version 26.1 and higher allows you to trigger the debugger when a variable changes. Place the following code near the beginning of your init.el:
Restart your emacs. Each time the variable is changed, you'll enter the debugger with the corresponding backtrace. After each occurence you ...
In a comment to @Drew's answer you've said:
Doesn't this require the user to use customize-set-variable instead of setq or setq-default ?
Indicating that you want your function to be called even when a variable is set by the likes of setq, which means you're looking for the variable-watcher functionality.
Refer to C-hig (elisp)Watching Variables for ...
It's not true that :set is used only for interactive use of Customize.
Functions customize-set-variable and customize-save-variable respect the :set function of the defcustom.
customize-set-variable is an interactive autoloaded compiled Lisp
function in cus-edit.el.
(customize-set-variable VARIABLE VALUE &optional COMMENT)
Set the default ...
It sounds like you have done both of the following for some options, i.e., you've done them both for at least one option:
Used Customize to set and save the option.
Tried to call customize functions to set the option in your init file.
If so, it's you who introduced the redundancy. For a given option, choose one or the other. For example, if you want to ...