That’s what copyto! does, it writes the elements of one array to another and returns the latter. Af = t -> A is a function that does nothing with its input and accesses the global variable A, then returns the array assigned to A. Bf does the same with global B. As a result, C is assigned to the same array as A is, you can verify with C === A.
I encountered this issue in a function, where I believe A and B were not global. I even not used copyto! but another function which overwrites the result. I thought that the value of A is embedded in the function Af and therefore hidden and protected against modifications. I am using a simple fix for the issue
C = copyto!(copy(Af(0)),Bf(0))
which, I admit, is silly but it works.
Still I wonder how the copying involving two numerical matrices Af(0) and Bf(0) can change the value of A which served for the definition of the function Af(t).
This would also mean that the matrix A in the definition of Af(t) can be accessed somehow. Very eager to learn how.
Thanks for these additional clarifications. I must confess I completely ignored these facts in implementing a number of functions for manipulating periodic matrices in the PeriodicSystems package, which are defined via function mappings.