You encountered a special kind of function. From the language definition (section 3.1.3 Function calls):
A special type of function calls can appear on the left hand side of
the assignment operator as in
class(x) <- "foo"
What this construction really does is to call the function class<-
with the original object and the right hand side.
This function performs the modification of the object and returns the
result which is then stored back into the original variable. (At least
conceptually, this is what happens. Some additional effort is made to
avoid unnecessary data duplication.)
Such functions are .Primitive
functions. They call internal C code. Usually they are generic functions, which means you can define methods for them.
@alexis_laz demonstrates how to create such a function in his comment:
second <- function(x) x[2]
"second<-" <- function(x, value) { x[2] <- value; x }
xx <- 1:3
second(xx)
#[1] 2
second(xx) <- 4
xx
#[1] 1 4 3